package day.day04;

import java.util.Random;
import java.util.Scanner;

public class Gussing {
    public static void main(String[] args) {
        Random rand = new Random();
         int num=rand.nextInt(300);
        System.out.println(num);
         //int num =(int)(Math.random()*1000+1)
        Scanner sc = new Scanner(System.in);
        /*System.out.println("猜吧 ");
        int gus = sc.nextInt();
        while (gus != num) {
            if (gus > num) {
                System.out.println("猜大了");
            }
            else {
                System.out.println("小了");
            }
            System.out.println("继续猜吧");
            gus = sc.nextInt();

        }
        System.out.println("猜对了");
        */

        /*
        补充：
        1.变量的作用域/范围：
           从变量的声明开始，到半酣它最近的大括号结束
         */

        int guess;
        do{
            System.out.println("猜吧");
            guess=sc.nextInt();
            {
                if (guess > num) {
                    System.out.println("猜大了");
                }
                else if(guess < num){
                    System.out.println("小了");
                }else{
                    System.out.println("猜对了");
                }
            }
        }while(guess!=num);

    }
}
